package com.dotlink.appuser.service.impl;

import java.sql.SQLException;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dotlink.appuser.dao.UserInfoDao;
import com.dotlink.appuser.entity.UserInfo;
import com.dotlink.appuser.service.UserInfoService;
import com.dotlink.frame.utils.page.Pagination;

@Service("userInfoService")
public class UserInfoServiceImpl implements UserInfoService {

	private static final Log log = LogFactory.getLog(UserInfoServiceImpl.class);

	@Autowired
	private UserInfoDao userInfoDao;

	@Override
	public Integer saveUser(UserInfo entity) {
		Integer res = 0;
		try {
			res = userInfoDao.saveUser(entity);
		} catch (SQLException e) {
			log.error(e.getMessage());
		}
		return res;
	}

	@Override
	public Integer updateUser(UserInfo entity) {
		Integer res = 0;
		try {
			res = userInfoDao.updateUser(entity);
		} catch (SQLException e) {
			log.error(e.getMessage());
		}
		return res;
	}

	@Override
	public List<UserInfo> list(UserInfo user, Pagination pagination) {
		List<UserInfo> users = null;
		try {
			users = userInfoDao.listPageUser(user, pagination);
		} catch (SQLException e) {
			log.error(e.getMessage());
		}
		return users;
	}

	@Override
	public UserInfo queryUserInfo(UserInfo user) {
		UserInfo userinfo = null;
		try {
			userinfo = userInfoDao.queryUserInfo(user);
		} catch (SQLException e) {
			log.error(e.getMessage());
		}
		return userinfo;
	}

}
